package cn.afactory.tygz.ui;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.AttributeSet;
import android.view.View;

import com.tendcloud.tenddata.TCAgent;

import cn.afactory.tygz.R;
import cn.afactory.tygz.ui.base.BaseActivity;
import cn.afactory.tygz.ui.base.utils.SPUtils;
import cn.afactory.tygz.ui.fragments.BlackListFragment;
import cn.afactory.tygz.ui.fragments.MyAlbumsFragment;

/**
 * Created with Android Studio.
 * Title:BlackListActivity
 * Description:
 * Copyright:Copyright (c) 2015
 * Company:和平必胜、正义必胜、人民必胜
 * Author:炎黄子孙
 * Date:15/9/15
 * Time:下午1:05
 * Version 1.0
 */
public class MyAlbumstActivity extends BaseActivity{
    private MyAlbumsFragment mFragment;
    private long mUserId;
    private String mUserName;
    private void initTitleBar() {
//        setTitleText("我的相册");
//        showBackView();
    }

    /**
     * 跳转相册管理页面
     * @param context
     * @param userId
     */
    public static void gotoMyAlbumstActivity(Context context,long userId,String nickName){
        Intent intent = new Intent(context,MyAlbumstActivity.class);
        intent.putExtra(SPUtils.EXTRA_USER_ID,userId);
        intent.putExtra(SPUtils.EXTRA_NICK_NAME,nickName);
        context.startActivity(intent);
    }

    @Override
    public View onCreateView(String name, Context context, AttributeSet attrs) {
        return super.onCreateView(name, context, attrs);
    }

    @Override
    public void onResume() {
        super.onResume();
        TCAgent.onResume(this);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addTitleBar = false;
        setContentView(R.layout.ac_fragment);

        mUserId = getIntent().getLongExtra(SPUtils.EXTRA_USER_ID,-1);
        mUserName = getIntent().getStringExtra(SPUtils.EXTRA_NICK_NAME);

        initview();
        initTitleBar();
    }

    private void initview() {
        mFragment = new MyAlbumsFragment(mUserId,mUserName);
        if (mFragment != null) {
            addFragment(mFragment);
        } else {
            finish();
        }
    }

    private void addFragment(Fragment fragment) {
        getSupportFragmentManager().beginTransaction()
                .add(R.id.fl_layout, fragment, "" + fragment.getClass())
                .commit();
    }
}
